<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传画作</title>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
            color: #fff;
            background: radial-gradient(circle, #0f2027, #203a43, #2c5364);
            overflow-y: auto;
        }
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: repeating-linear-gradient(
            0deg,
            rgba(0, 255, 255, 0.2) 0,
            rgba(0, 255, 255, 0.2) 1px,
            transparent 1px,
            transparent 30px
            ),
            repeating-linear-gradient(
            90deg,
            rgba(0, 255, 255, 0.2) 0,
            rgba(0, 255, 255, 0.2) 1px,
            transparent 1px,
            transparent 30px
            ),
            radial-gradient(circle, rgba(0, 128, 192, 0.3), transparent 70%);
            animation: grid-animation 20s linear infinite, glow-animation 5s ease-in-out infinite;
            z-index: -1;
        }
        @keyframes grid-animation {
        0% {
            transform: translate(0, 0);
        }
        100% {
            transform: translate(-30px, -30px);
        }
        }
        @keyframes glow-animation {
        0%, 100% {
            filter: brightness(1);
        }
        50% {
        filter: brightness(1.5);
        }
        }
        .navbar {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            width: 100%;
            padding: 10px 20px;
            background-color: rgba(0, 0, 0, 0.8);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 10;
        }
        .navbar a {
            flex: 1;
            text-align: center;
            padding: 15px 0;
            font-size: 18px;
            font-weight: bold;
            text-decoration: none;
            color: #fff;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 5px;
            transition: background-color 0.3s, transform 0.2s;
        }
        .navbar a.active {
            background-color: rgba(0, 255, 255, 0.6);
        }
        .navbar a:hover:not(.active) {
            background-color: rgba(0, 255, 255, 0.3);
            transform: scale(1.05);
        }
        .container {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            max-width: 600px;
            width: 90%;
            padding: 40px;
            margin: 100px auto 20px;
            border-radius: 10px;
            background-color: rgba(0, 0, 0, 0.4);
            text-align: center;
        }
        h1 {
            font-size: 24px;
            margin-bottom: 10px;
        }
        .artist-list-container {
            position: absolute;
            left: 20px;
            top: 100px;
            max-width: 200px;
            max-height: 600px;
            overflow-y: auto;
            background-color: rgba(0, 0, 0, 0.3);
            border-radius: 10px;
            padding: 10px;
        }
        .artist-list-container h2 {
            font-size: 20px;
            margin: 0 0 10px;
            text-align: center;
        }
        .artist-list {
            list-style-type: none;
            padding: 0;
            margin: 0;
            font-size: 20px;
        }
        input[type="file"] {
            display: none;
        }
        .custom-file-upload, button {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        padding: 10px 20px;
        font-size: 16px;
        cursor: pointer;
        background-color: transparent;
        color: #00d4ff;
        border: 0;
        border-top: 2px solid #00d4ff;
        border-bottom: 2px solid #00d4ff;
        transition: transform 0.3s ease, background-color 0.3s ease;
        }
        .custom-file-upload:hover, button:hover {
        transform: scale(1.05);
        background-color: rgba(0, 212, 255, 0.2);
        }
        .custom-file-upload:active, button:active {
        transform: scale(1.02);
        background-color: rgba(0, 212, 255, 0.4);
        }
        .custom-file-upload {
        margin-right: 20px;
        }
        .chat-container {
        position: fixed;
        right: 20px;
        bottom: 20px;
        width: 350px;
        max-height: 600px;
        display: flex;
        flex-direction: column;
        background-color: rgba(0, 0, 0, 0.85);
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        }
        .chat-display {
        flex: 1;
        padding: 10px;
        overflow-y: auto;
        color: #fff;
        font-size: 16px;
        line-height: 1.6;
        }
        .chat-input-area {
        display: flex;
        padding: 10px;
        background-color: rgba(0, 0, 0, 0.6);
        }
        .chat-input-area input {
        flex: 1;
        padding: 8px;
        font-size: 16px;
        border: none;
        border-radius: 5px;
        margin-right: 10px;
        }
        .chat-input-area button {
        padding: 8px 12px;
        font-size: 16px;
        background-color: #00d4ff;
        color: #fff;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        transition: background-color 0.3s;
        }
        .chat-input-area button:hover {
        background-color: #00a3cc;
        }
        .chat-message {
        max-width: 60%;
        margin-bottom: 10px;
        padding: 8px 12px;
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        word-wrap: break-word;
        font-size: 16px;
        white-space: pre-wrap;
        }
        .chat-message.user {
        margin-left: auto;
        text-align: right;
        border-color: #00d4ff;
        background-color: rgba(0, 212, 255, 0.2);
        }
        .chat-message.ai {
        margin-right: auto;
        text-align: left;
        border-color: #ff6b6b;
        background-color: rgba(255, 107, 107, 0.2);
        }
        .image-preview {
            margin-top: 20px;
            max-width: 100%;
            border-radius: 10px;
        }
        .small-text {
            font-size: 12px;
            color: #ddd;
            margin-top: 5px;
        }
        ::-webkit-scrollbar {
            width: 10px;
        }
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        border-radius: 0;
        }
        ::-webkit-scrollbar-thumb {
            background: rgba(0, 212, 255, 0.7);
            border-radius: 0;
        }
        ::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 212, 255, 0.8);
        }
        button.disabled {
        background-color: #ccc;
        color: #666;
        cursor: pointer;
        }
    </style>
</head>
<body data-page-id="page1">

    <div class="navbar">
        <a href="#" class="active">上传画作</a>
        <a href="/recognize" style="pointer-events: none; opacity: 0.5;">识别成功</a>
    </div>

    <div class="container">
        <h1>看图猜作者</h1>
        <p class="small-text">(上传画作让AI识别作者，结果仅供参考，并非一定正确)</p>
        <form method="POST" enctype="multipart/form-data" class="upload-section">
            {% csrf_token %}
            <label for="image" class="custom-file-upload">选择图片上传</label>
            <input type="file" id="image" name="image" accept="image/*" required onchange="previewImage(event)">
            <button type="submit">识别图片作者</button>
        </form>
        <img id="preview" class="image-preview" alt="Preview" style="display: none;">
    </div>

    <div class="artist-list-container">
        <h2>可识别作品的画家</h2>
        <ul class="artist-list">
            {% for artist in class_names %}
                <li>{{ artist }}</li>
            {% endfor %}
        </ul>
    </div>

    <div class="chat-container">
    <div id="chat-display" class="chat-display"></div>
    <div class="chat-input-area">
    <button id="voice-mode-btn" class="disabled" onclick="toggleVoiceMode()">开启语音模式</button>
    <input type="text" id="chat-input" placeholder="在此输入指令" onkeypress="handleChatInput(event)">
    <button onclick="processChat()">发送</button>
    </div>
    </div>
    
    <script>
        function previewImage(event) {
            const preview = document.getElementById('preview');
            preview.src = URL.createObjectURL(event.target.files[0]);
            preview.style.display = 'block';
        }
    </script>
    
    {% load static %}
    <script src={% static 'chat.js' %}></script>
    
</body>
</html>